home *** CD-ROM | disk | FTP | other *** search
/ Gold Medal Software 1 / Gold Medal Software Volume 1 (Gold Medal) (1994).iso / prog / tpwprog7.arj / CONTROL.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1992-07-02  |  1.7 KB  |  75 lines

  1. { control.pas -- Demonstrate how to use control objects }
  2.  
  3. program Control;
  4.  
  5. uses WinTypes, WinProcs, WObjects, Strings;
  6.  
  7. type
  8.  
  9.   ControlApplication = object(TApplication)
  10.     procedure InitMainWindow; virtual;
  11.   end;
  12.  
  13.   PControlWindow = ^ControlWindow;
  14.   ControlWindow = object(TWindow)
  15.     OkButton: PButton;
  16.     constructor Init(AParent: PWindowsObject; ATitle: PChar);
  17.     procedure SetupWindow; virtual;
  18.     procedure IDOk(var Msg: TMessage);
  19.       virtual id_First + id_Ok;
  20.   end;
  21.  
  22.  
  23. { ControlApplication }
  24.  
  25. {- Initialize ControlApplication object's window }
  26. procedure ControlApplication.InitMainWindow;
  27. begin
  28.   MainWindow := New(PControlWindow, Init(nil, 'Control'))
  29. end;
  30.  
  31.  
  32. { ControlWindow }
  33.  
  34. {- Construct ControlWindow object }
  35. constructor ControlWindow.Init(AParent: PWindowsObject; ATitle: PChar);
  36. begin
  37.   TWindow.Init(AParent, ATitle);
  38.   EnableKBHandler;
  39.   with Attr do
  40.   begin
  41.     X := 0; Y := 0; W := 500; H := 350
  42.   end;
  43.   OkButton := New(PButton, Init(@Self, id_Ok, 'Ok',
  44.     390, 280, 80, 30, true));
  45. end;
  46.  
  47. {- Perform jobs requiring an initialized window handle }
  48. procedure ControlWindow.SetupWindow;
  49. begin
  50.   TWindow.SetupWindow;
  51.   SetFocus(OkButton^.HWindow);
  52. end;
  53.  
  54. {- Respond to selection of Ok button }
  55. procedure ControlWindow.IDOk(var Msg: TMessage);
  56. begin
  57.   CloseWindow
  58. end;
  59.  
  60. var
  61.  
  62.   ControlApp: ControlApplication;
  63.  
  64. begin
  65.   ControlApp.Init('ControlApp');
  66.   ControlApp.Run;
  67.   ControlApp.Done
  68. end.
  69.  
  70.  
  71. {--------------------------------------------------------------
  72.   Copyright (c) 1991 by Tom Swan. All rights reserved.
  73.   Revision 1.00    Date: 5/9/1991
  74. ---------------------------------------------------------------}
  75.